//
//  JMAppDelegate.m
//  JMSM4.0
//
//  Created by Cansing on 09/12/2024.
//  Copyright (c) 2024 Cansing. All rights reserved.
//

#import "JMAppDelegate.h"
#import "SM4Crypto.h"
#import "GMObjC.h"

@implementation JMAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    /**
     原始数据：13859927760
     时间戳：1726139223070
     日期：20240912190703
     secretKey = kksfXX_BzW=ghmHM
     iv = 1726139223070ygj
     Sm4加密后：394984d23034dc65a4b3eed094ef7c10
     Base64编码后：OUmE0jA03GWks+7QlO98EA==
     Base64解码后：394984d23034dc65a4b3eed094ef7c10
     Sm4解密后：13859927760
     */

    NSDictionary*dic=[SM4Crypto sm4Encrypt:@"kksfXX_BzW=ghmHM" withPlainText:@"13859927760" withTime:1726139223070];

    NSLog(@"%@",dic);


    return YES;
}

- (NSString *)convertStringToHexString:(NSString *)string {
    NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
    NSMutableString *hexString = [NSMutableString stringWithCapacity:data.length * 2];

    const unsigned char *bytes = data.bytes;
    for (NSInteger i = 0; i < data.length; i++) {
        [hexString appendFormat:@"%02x", bytes[i]];
    }

    return [hexString copy];
}


- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
